/**
 * 参考golang gin 与 springmvc lookuphandle实现的路由查找
 */
package com.server.core.util;

import com.server.core.action.AbstractAction;

import java.util.HashMap;

public class SingletonActionUtil {

    public static HashMap<Class, AbstractAction> actionSet = new HashMap<>();

    public static AbstractAction getAction(Class clzz)throws Exception {

         try{
             if(!actionSet.containsKey(clzz)) {
                 actionSet.put(clzz, (AbstractAction)clzz.newInstance());
             }
             return actionSet.get(clzz);
         }catch (InstantiationException e) {
             e.printStackTrace();
         }catch (IllegalAccessException e) {
             e.printStackTrace();
         }catch (NullPointerException e) {

         }
         return null;
    }

}
